package com.qipay.baas.mapper;

import com.qipay.baas.model.Configuration;
import com.qipay.baas.model.ConfigurationExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ConfigurationMapper {
    @SelectProvider(type=ConfigurationSqlProvider.class, method="countByExample")
    int countByExample(ConfigurationExample example);

    @Delete({
        "delete from `configuration`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into `configuration` (`id`, `type`, ",
        "`value`, `info`)",
        "values (#{id,jdbcType=BIGINT}, #{type,jdbcType=TINYINT}, ",
        "#{value,jdbcType=VARCHAR}, #{info,jdbcType=VARCHAR})"
    })
    int insert(Configuration record);

    @InsertProvider(type=ConfigurationSqlProvider.class, method="insertSelective")
    int insertSelective(Configuration record);

    @SelectProvider(type=ConfigurationSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="type", property="type", jdbcType=JdbcType.TINYINT),
        @Result(column="value", property="value", jdbcType=JdbcType.VARCHAR),
        @Result(column="info", property="info", jdbcType=JdbcType.VARCHAR)
    })
    List<Configuration> selectByExample(ConfigurationExample example);

    @Select({
        "select",
        "`id`, `type`, `value`, `info`",
        "from `configuration`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="type", property="type", jdbcType=JdbcType.TINYINT),
        @Result(column="value", property="value", jdbcType=JdbcType.VARCHAR),
        @Result(column="info", property="info", jdbcType=JdbcType.VARCHAR)
    })
    Configuration selectByPrimaryKey(Long id);

    @UpdateProvider(type=ConfigurationSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Configuration record);

    @Update({
        "update `configuration`",
        "set `type` = #{type,jdbcType=TINYINT},",
          "`value` = #{value,jdbcType=VARCHAR},",
          "`info` = #{info,jdbcType=VARCHAR}",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Configuration record);
}